<?php

include_once ("Usuario.php");

class LoginControle extends Controle {

    function logar() {

        session_start();

        $model = new Usuario();
        $resultUsuario = array();

        $model->usarUserBd($this->data['email'], $this->data['senha'], 'nailtonv_projeto', 'localhost', '3306');
        $resultUsuario = $model->find2(array('conditions' => array('email = ' => $this->data['email'], 'senha =' => $this->data['senha'])));

        foreach ($resultUsuario as $row) {
            $_SESSION['categoria'] = $row['categoria_id'];
            $_SESSION['usuario_id'] = $row['id'];
            $this->set('title_for_layout', $row['nome']);
        }


        print $_SESSION['categoria'];
        print $_SESSION['usuario_id'];

        $this->set("data", $resultUsuario);
        $this->render("index");
    }

    function logoff() {
        session_start();
        session_destroy();
        $this->render("index");
    }

    function index() {
        
    }

}

?>
